#ifndef __CLIENT_SYNC_H__
#define __CLIENT_SYNC_H__

#include <poller.h>
#include <global.h>
#include <noncopyable.h>


HTTP_SVR_NS_BEGIN

class THttpStateInfo;
class CHttpDecoder;
class CDecoderUnit;

class CClientUnit : public CPollerObject, private noncopyable
{
public:
	CClientUnit (CDecoderUnit*, THttpStateInfo*);
	virtual ~CClientUnit ();

    int Attach (void);

    inline CConnState get_state (void) { return _stage; }

    inline int get_netfd (void) { return netfd; }

	int recv (void);
	int response (void);

    int add_rsp_buffer(char* buffer, int len, int type = RSP_NORMAL_ITEM);
	
private:
	virtual int InputNotify (void);
	virtual int OutputNotify (void);
    virtual int HangupNotify (void);

private:
    CConnState          _stage;
    CHttpDecoder*       _decoder;
    CDecoderUnit*       _owner;
    THttpStateInfo*     _httpinfo;
    int                 _accesstimes:1;

    TRspList*           _rspList;
    TRspList*           _rspLastItem;
};

HTTP_SVR_NS_END

#endif

